<template>
	<view class="cases">
		<view class="list">
			<block v-for="(item,index) in list" :key="index">
				<view class="item acea-row row-middle" @click="detailClick(item)">
					<view class="">
						<image class="avatar" :src="item.image_input[0]" mode="aspectFit"></image>
					</view>
					<view class="text acea-row row-between row-column ml20">
						<view class="line2 fs-30 color333 bold" style="min-height: 80rpx;">{{ item.title }}</view>
						<view class="btn mt10">查看详情</view>
					</view>
				</view>
			</block>
		</view>
		
		<view class='loadingicon acea-row row-center-wrapper' v-if="list.length>0">
			<text class='loading iconfont icon-jiazai' :hidden='loading==false'></text>{{loadTitle}}
		</view>
		
		<block v-if="list.length==0">
			<view class="kong">
				<view class="acea-row row-middle row-center none-t">
					<text class="fs-32 color666">暂无更多数据~</text>
				</view>
			</view>
		</block>
		
		<suspension></suspension>
		
	</view>
</template>

<script>
	import{
		caseslist
	} from '@/api/api.js'
	import suspension from '@/components/suspension.vue';
	export default {
		components:{
			suspension
		},
		data() {
			return {
				page:1,
				limit:10,
				list:[],
				loadend: false,
				loading: false,
				loadTitle: this.$t(`加载更多`),
				
			};
		},
		onLoad() {
			this.getlist();
		},
		methods:{
			getlist(){
				let that = this;
				if (that.loadend) return;
				if (that.loading) return;
				that.loading = true;
				that.loadTitle = '';
				caseslist({ page:that.page,limit:that.limit }).then(res=>{
					let list = res.data;
					let arr = that.$util.SplitArray(list, that.list);
					let loadend = list.length < that.limit;
					that.loadend = loadend;
					that.loading = false;
					that.loadTitle = loadend ? that.$t(`没有更多内容啦~`) : that.$t(`加载更多`);
					that.$set(that, 'list', arr);
					that.$set(that, 'page', that.page + 1);
				}).catch(err=>{
					that.loading = false;
					that.loadTitle = that.$t(`加载更多`);
				})
			},
			detailClick(item){
				uni.navigateTo({
					url: '/pages/newIndex/cases-details?id=' + item.id
				})
			}
		},
		onReachBottom(){
			this.getlist();
		}
	}
</script>

<style lang="scss">
	.cases{
		
		.list{
			width: 100%;
			background-color: #ffffff;
			padding: 0 30rpx;
			
			.item{
				width: 100%;
				padding: 30rpx 0;
				border-bottom: 1rpx solid #E4E4E4;
				
				.avatar{
					width: 180rpx;
					height: 170rpx;
					// border: 1rpx solid red;
					border-radius: 10rpx;
					overflow: hidden;
				}
				.text{
					width: 490rpx;
				}
				.btn{
					width: 222rpx;
					height: 60rpx;
					line-height: 60rpx;
					text-align: center;
					border-radius: 30rpx;
					background: rgba(253, 125, 54, 0.2);
					color: #FD7D36;
					font-size: 28rpx;
				}
			}
			
		}
		
		.kong{
			width: 520rpx;
			height: 520rpx;
			background-image: url('https://yijiaan.oss-cn-hangzhou.aliyuncs.com/pic/none-icon.png');
			background-size: 100% 100%;
			margin: 30rpx auto;
			position: relative;
			
			.none-t{
				width: 100%;
				color: #888888;
				font-size: 34rpx;
				position: absolute;
				bottom: -20rpx;
				left: 0;
				right: 0;
			}
		}
	}
</style>
